package com.simple.orm.mybatis;

/**
 * 功能描述: 默认的工厂实现，可以拿到sql会话
 *
 * @author: WuChengXing
 * @create: 2021-12-28 13:53
 **/
public class DefaultSqlSessionFactory implements SqlSessionFactory {

    private final Configuration configuration;

    public DefaultSqlSessionFactory(Configuration configuration) {
        this.configuration = configuration;
    }

    @Override
    public SqlSession openSession() {
        // 将连接信息传递下去，也即通过默认工厂生成一个sql会话
        return new DefaultSqlSession(configuration.connection, configuration.mapperElement);
    }
}
